package com.huyanqi.core.service;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Map;

import com.huyanqi.core.BaseDomainObject;

/**
 * 
 * <p>Title: BaseFrontService.java</p>
 * 
 * <p>Description: 前端页面调用Service基类</p>
 * 
 * <p>Datetime: 2011-12-26 下午1:25:36</p>
 *
 * @company 成都映潮科技有限公司
 * 
 * @author <a href="mailto:liwei@sunsharp.cn">p.k.ripper</a>
 *
 */
public interface BaseFrontService<Entity extends BaseDomainObject,PK extends Serializable> {
	/**
	 * 增加实体
	 * 
	 * @param entity
	 * @return
	 */
	public Entity save(Entity entity) throws Exception;

	/**
	 * 更新实体
	 */
	public void update(Entity entity) throws Exception;
	/**
	 * 删除实体
	 * @param entity
	 */
	public void delete(Entity entity) throws Exception;		
	/**
	 * 批量删除
	 */
	public void delete(PK[] ids) throws Exception;

	/**
	 * 按ID删除对象
	 * 
	 * @param id
	 */
	public void delete(final PK id) throws Exception;

	/**
	 * 按ID查询对象
	 * 
	 * @param id
	 * @return
	 */
	public Entity findById(final PK id) throws Exception;

	/**
	 * 按ID查询多个对象
	 * 
	 * @param ids
	 * @return
	 */
	public List<Entity> findByIds(final Collection<PK> ids) throws Exception;
	
	/**
	 * 根据属性查询
	 * @param propertyName
	 * @param value
	 * @return List<Entity>
	 */
	public List<Entity> findByProperty(String propertyName, Object value) throws Exception;

	/**
	 * 根据多个属性查(相等)
	 * @param values
	 * @return List<Entity>
	 * @throws Exception
	 */
	public List<Entity> findByProperty(Map<String, Object> values) throws Exception ;
}
